<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/fabric@4.6.0/dist/fabric.min.js"></script>
</head>
<body>
  <!-- <img src="https://img1.baidu.com/it/u=3206351602,2714439067&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500" alt=""> -->
  <!-- <img src="./assets/imgs/Snipaste_2022-10-25_11-11-58.png" alt=""> -->
  <canvas width="400" height="375" id="canvas" style="border: 1px solid #ccc;"></canvas>
  <script>
    // 绘制一个 canvas
    const canvas = new fabric.Canvas('canvas')
    
    const polyline = new fabric.Polyline(
      [
        {x: 30, y: 30},
        {x: 150, y: 140},
        {x: 240, y: 150},
        {x: 100, y: 30},
      ], {
        fill: 'transparent', // 如果画折线，填充色需要是透明的,默认是黑色
        stroke: '#6639a6', // 线段颜色
        strokeWidth: 5 // 线段宽度
      }
    )

    canvas.add(polyline)
    // new fabric.Polyline 是不会自动把 起始点 和 结束点 自动闭合起来的

  </script>
</body>
</html>